﻿using System.Linq;

namespace UniSender
{
    public class LogItem
    {
        public int Index { get; set; }
        public string Code { get; set; }
        public string Message { get; set; }

        public LogItem()
        { }

        public LogItem(Native.LogItem native)
        {
            Index = native.index;
            Code = native.code;
            Message = native.message;
        }
    }

    public class ImportResult
    {
        public int Total{ get; set; }
        public int Inserted{ get; set; }
        public int Updated{ get; set; }
        public int Deleted{ get; set; }
        public int NewEmails{ get; set; }
        public int Invalid{ get; set; }
        public LogItem[] Log{ get; set; }

        public ImportResult()
        { }

        public ImportResult(Native.ImportResult native)
        {
            Total = native.total;
            Inserted = native.inserted;
            Updated = native.updated;
            Deleted = native.deleted;
            NewEmails = native.new_emails;
            Invalid = native.invalid;
            Log = native.log.IfNotNull(log => log.Select(item => new LogItem(item)).ToArray());
        }
    }
}
